/*     */ package com.iris.egrant.service.proposal;
/*     */ 
/*     */

import com.iris.egrant.exception.ServiceException;
import com.iris.egrant.model.formInit.FormBaseLibrary;
import com.iris.egrant.model.proposal.ProposalCached;
import com.iris.egrant.model.proposal.ProposalCachedExtend;
import com.iris.egrant.utils.XMLHelper;
import org.apache.commons.lang.StringUtils;
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ @Service("proposalNoTransService")
/*     */ public class ProposalNoTransServiceImpl
/*     */   implements ProposalNoTransService
/*     */ {
/*  39 */   private static final Logger LOGGER = LoggerFactory.getLogger(ProposalNoTransServiceImpl.class);
/*     */ 
/*     */   
/*     */   @Autowired
/*     */   private ProposalReadService proposalReadService;
/*     */ 
/*     */   
/*     */   @Autowired
/*     */   private ProposalService proposalService;
/*     */ 
/*     */ 
/*     */   
/*     */
/*     */   public Map<String, Object> getPrpLoad(Map<String, Object> params, Long posCode) throws ServiceException, UnknownHostException {
    /*  52 */     params.put("formType", "proposal");
    /*  53 */     params.put("psn_code", "100189124");
    /*  54 */     if (params.get("org_code") == null) {
        /*  55 */       params.put("org_code", "10032030");
        /*     */     }
    /*  57 */     Long grantCode = (Long)params.get("grant_code");
    /*  58 */     Long subGrantCode = (Long)params.get("sub_grant_code");
//    /*  59 */     GrantSetting gs = this.proposalReadService.getGrantSetting(subGrantCode);
//    /*  60 */     if (gs.getGrantLevel().intValue() == 2) {
        /*  61 */       params.put("grant_code", subGrantCode);
        /*  62 */       params.put("sub_grant_code", subGrantCode);
//        /*     */     } else {
//        /*  64 */       params.put("grant_code", gs.getParentCode());
//        /*  65 */       params.put("sub_grant_code", subGrantCode);
//        /*     */     }
    /*  69 */     if (subGrantCode != null) {
        /*  70 */       grantCode = subGrantCode;
        /*     */     }
    /*  73 */     Map<String, Object> resultMap = new HashMap<String, Object>();
    /*  74 */     FormBaseLibrary fbl = null;
            /*  77 */ params.put("actionType", Integer.valueOf(1));


            /*  78 */ fbl = this.proposalReadService.getFormBaseLibraryByGrantId(grantCode, 11146L, null, params);
//                           ProposalCachedExtend prpCachedExtend = this.proposalReadService.getProposalCachedExtend(posCode);
//    /* 354 */       fbl = this.proposalReadService.getFormBaseLibraryByGrantId(grantCode,11146L, XMLHelper.parseDoc(XMLHelper.StringToDoc(prpCachedExtend.getPrpXml())).asXML(), params);
    /* 355 */

                            params.put("dailu_psn_code", "100189124");
            /*     */     resultMap.put("prp_deadline", "2024-04-14");
        /*  86 */       resultMap.put("pro_start_date", "2024-04-14");
            /*  96 */   resultMap.put("pro_end_date",  "2024-04-14");
                             resultMap.put("statYear", "2024-04-14");
                             resultMap.put("is_first", Integer.valueOf(1));
    /*     */              resultMap.put("fbl", fbl);
    /* 137 */          resultMap.put("xmlData", fbl.getXmlData());
    /* 138 */     return resultMap;
    /*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public Map<String, Object> savePrp(Long posCode, Long grantCode, String xmlData) throws DocumentException {
/* 145 */     Map<String, Object> returnMap = new HashMap<String, Object>();
/* 146 */     ProposalCached prpCached = null;
/* 147 */     ProposalCachedExtend prpCachedExtend = null;
/* 148 */     if (posCode != null) {
/* 149 */       prpCached = this.proposalReadService.getProposalCache(posCode);
/*     */       
/* 151 */       String status = prpCached.getStatus();
/*     */       
/* 153 */       xmlData = XMLHelper.refreshNodeValue(xmlData, "data/proposal/prp_status", prpCached.getStatus());
/* 154 */       if (StringUtils.isNotBlank(status)) {
/* 155 */         synchronized (this) {
/* 156 */           if (!status.equals("10") && !status.equals("00")) {
/* 157 */             returnMap.put("message", "isSubmit");
/* 158 */             return returnMap;
/*     */           } 
/*     */         } 
/*     */       }
/*     */     } 
/*     */     
/* 164 */     String prpVersion = null;
/* 165 */     String subGrantCode = null;
/* 166 */     String helpGrantCode = null;
/* 167 */     String psnCode = null;
/* 168 */     String grantNo = null;
/*     */     
///* 170 */     if (SecurityUtils.getCurrentUserId() == null || SecurityUtils.getCurrentUserId().longValue() == 0L) {
/* 171 */       this.proposalService.setReturnMap(returnMap, "saveError", prpVersion, xmlData, posCode);
/* 172 */       return returnMap;
///*     */     }
///*     */
///* 175 */     Document doc = XMLHelper.parseDocument(xmlData);
///*     */     try {
///* 177 */       subGrantCode = XMLHelper.getNodeValueFromXML(doc, "/data/proposal/sub_grant_code");
///* 178 */       helpGrantCode = XMLHelper.getNodeValueFromXML(doc, "/data/proposal/help_grant_code");
///* 179 */       grantNo = XMLHelper.getNodeValueFromXML(doc, "/data/proposal/grant_no");
///* 180 */       psnCode = XMLHelper.getNodeValueFromXML(doc, "/data/proposal/psn_code");
///*     */
///* 182 */       if (psnCode == null || psnCode.equalsIgnoreCase("")) {
///* 183 */         psnCode = XMLHelper.getNodeValueFromXML(doc, "/data/zh_persons/zh_person[@submit_psn=1]/basic_info/psn_code");
///*     */       }
///* 185 */     } catch (Exception e) {
///* 186 */       LOGGER.error("保存申请书-XML解析失败\n" + doc.asXML(), e);
///* 187 */       getSysLogService().createSysLog(SecurityUtils.getCurrentUserId(), SysLogType.proposal, ObjectUtils.toString(posCode), "保存申请书-XML解析失败", doc.asXML(), getStackTraceMessege(e));
///* 188 */       this.proposalService.setReturnMap(returnMap, "saveErrorProgramThrow", "", "", posCode);
///* 189 */       return returnMap;
///*     */     }
///*     */
///*     */     try {
///* 193 */       if (posCode != null) {
///* 194 */         prpCached = this.proposalReadService.getProposalCache(posCode);
///* 195 */         prpCachedExtend = this.proposalReadService.getProposalCachedExtend(posCode);
///* 196 */         prpVersion = prpCached.getPrpVersion();
///*     */
///* 198 */         if (prpCached.getPsnCode().longValue() != SecurityUtils.getCurrentUserId().longValue() && !SecurityUtils.isAuthority("A_DAILU_PROPOSAL")) {
///* 199 */           this.proposalService.setReturnMap(returnMap, "saveError", prpVersion, doc.asXML(), posCode);
///* 200 */           return returnMap;
///*     */         }
///*     */
///* 203 */         Document oldDoc = XMLHelper.parseDoc(prpCachedExtend.getPrpXml());
///* 204 */         Document newDoc = doc;
///*     */
///*     */
///*     */
///*     */
///*     */
///*     */
///* 211 */         Document oldW3C = XMLHelper.parseW3cDoc(oldDoc.asXML());
///* 212 */         Document newW3C = XMLHelper.parseW3cDoc(doc.asXML());
///*     */
///* 214 */         Map<String, Object> compare = XMLHelper.compareXml(XMLHelper.parseDoc(oldW3C), XMLHelper.parseDoc(newW3C));
///*     */
///* 216 */         if (((Boolean)compare.get("same")).booleanValue()) {
///* 217 */           this.proposalService.setReturnMap(returnMap, "saveSame", prpVersion, doc.asXML(), posCode);
///* 218 */           return returnMap;
///*     */         }
///*     */       } else {
///*     */
///* 222 */         prpCached = new ProposalCached();
///* 223 */         prpCachedExtend = new ProposalCachedExtend();
///* 224 */         prpCached.setCreatePsnCode(SecurityUtils.getCurrentUserId());
///* 225 */         prpCached.setCreateDate(new Date());
///*     */       }
///*     */
///* 228 */       GrantSchedule grantSchedule = this.proposalReadService.getGrantSchedule(Long.valueOf(Long.parseLong(subGrantCode)));
///* 229 */       String batch = IrisStringUtils.toString(grantSchedule.getBatch());
///* 230 */       prpCached.setBatch(batch);
///*     */
///* 232 */       if (psnCode != null && !psnCode.equals("")) {
///* 233 */         prpCached.setPsnCode(Long.valueOf(psnCode));
///*     */       } else {
///* 235 */         prpCached.setPsnCode(SecurityUtils.getCurrentUserId());
///*     */       }
///* 237 */       prpCached.setSubmitPsnCode(SecurityUtils.getCurrentUserId());
///* 238 */       prpCached.setUpdatePsnCode(SecurityUtils.getCurrentUserId());
///* 239 */       prpCached.setUpdateDate(new Date());
///* 240 */       if (StringUtils.isBlank(prpCached.getStatus())) {
///* 241 */         prpCached.setStatus("00");
///*     */       }
///*     */
///* 244 */       this.proposalService.savePrpTrans(grantCode, prpCached, prpCachedExtend, returnMap, prpVersion, subGrantCode, helpGrantCode, grantNo, doc);
///* 245 */       posCode = Long.valueOf(NumberUtils.toLong(ObjectUtils.toString(returnMap.get("pos_code"))));
///* 246 */       this.proposalService.prpSplit(Character.valueOf('1'), doc, posCode);
///* 247 */       this.proposalService.processAfterSaveProposalCached(posCode);
///*     */
///*     */
///*     */
///*     */
///*     */
///*     */
///*     */
///* 255 */       this.proposalService.saveContent(posCode, doc);
///*     */     }
///* 257 */     catch (Exception e) {
///* 258 */       LOGGER.error("保存申请书出错\n" + doc.asXML(), e);
///* 259 */       getSysLogService().createSysLog(SecurityUtils.getCurrentUserId(), SysLogType.proposal, ObjectUtils.toString(returnMap.get("pos_code")), "保存申请书出错", doc.asXML(), getStackTraceMessege(e));
///* 260 */       this.proposalService.setReturnMap(returnMap, "saveErrorProgramThrow", prpVersion, doc.asXML(), posCode);
///* 261 */       return returnMap;
///*     */     }
///*     */
///*     */
///* 265 */     getSysLogService().createSysLog(SysLogType.proposal, posCode.toString(), "申请书保存成功", xmlData);
///* 266 */     return returnMap;
///*     */   }
///*     */
///*     */
///*     */   private String getStackTraceMessege(Exception e) {
///* 271 */     StackTraceElement[] st = e.getStackTrace();
///* 272 */     StringBuffer msg = new StringBuffer("");
///* 273 */     if (null != e.getMessage()) {
///* 274 */       msg.append(e.getMessage());
///*     */     }
///* 276 */     for (StackTraceElement i : st) {
///* 277 */       msg.append("\n\tat " + i.toString());
///*     */     }
///* 279 */     return msg.toString();
/*     */   }
/*     */ 
/*     */   
/*     */ }


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-code-2.2.20240205.1659.jar!\com\iris\egrant\service\proposal\ProposalNoTransServiceImpl.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */